import { defineStore } from "pinia";
import getters from '@/store/getters'
export const systemStore = defineStore("systemStore", {
  state() {
    return {
      collapseSidebar: false,
      showGlobalAlert: false,
      screenWidth: 0,
      selectMenuPath: '/content',
      currentLocale: 'cn',
      showSideMenuDrawer: false,
      selectedSideMenuKey: ['/dashboard'],
      sideMenuOpenedKeys: []
    }
  },
  // getters: getters.selectMenuPath,
  actions: {
    toggleLocale(locale: string) {
      this.currentLocale = locale ? locale : 'cn';
    },
    toggleMenuPath(path: string) {
      this.selectMenuPath = path ? path : '/content';
    },
    toggleSidebar(collapseSidebar: boolean) {
      this.collapseSidebar = collapseSidebar;
    },
    toggleGlobalAlert(isShowAlert: boolean) {
      this.showGlobalAlert = isShowAlert;
    },
    toggleSideMenuDrawer() {
      this.showSideMenuDrawer = !this.showSideMenuDrawer;
    },

    updateScreenWidth(screenWidth: number) {
      this.screenWidth = screenWidth
      this.collapseSidebar = screenWidth <= 1366;
      if (screenWidth > 768) {
        this.showSideMenuDrawer = false;
      }
    },
    updateSelectedSidemenu(menuKey: string) {
      this.selectedSideMenuKey = [menuKey];
    },
    updateSideMenuOpenedKeys(openKeys: Array<string>) {
      // @ts-ignore
      this.sideMenuOpenedKeys = openKeys;
    },
  }
});
